package com.come4loves.game.module.fight.model;

import java.util.ArrayList;
import java.util.List;

import com.come4loves.game.module.fight.action.BuffAction;
import com.come4loves.game.module.fight.constants.CardLocation;
import com.come4loves.game.module.fight.helper.ActionRecorder;

public class MainCardArea {
	/**
	 * 主将卡
	 */
	private FightCard mainCard;
	/**
	 * 武器卡
	 */
	private FightCard weaponCard;
	/**
	 * 防具卡
	 */
	private FightCard defCard;
	/**
	 * 道具卡
	 */
	private FightCard itemCard;
	public MainCardArea(FightCard mainCard) {
		super();
		this.mainCard = mainCard;
	}
	public FightCard getMainCard() {
		return mainCard;
	}
	public void setMainCard(FightCard mainCard) {
		this.mainCard = mainCard;
	}
	public FightCard getWeaponCard() {
		return weaponCard;
	}
	public void setWeaponCard(FightCard weaponCard) {
		this.weaponCard = weaponCard;
	}
	public FightCard getDefCard() {
		return defCard;
	}
	public void setDefCard(FightCard defCard) {
		this.defCard = defCard;
	}
	public FightCard getItemCard() {
		return itemCard;
	}
	public void setItemCard(FightCard itemCard) {
		this.itemCard = itemCard;
	}
	
	public List<FightCard> allCards(){
		List<FightCard> list = new ArrayList<FightCard>();
		list.add(this.mainCard);
		if (this.weaponCard != null) {
			list.add(this.weaponCard);
		}
		if (this.defCard != null) {
			list.add(this.defCard);
		}
		if (this.itemCard != null) {
			list.add(this.itemCard);
		}
		return list;
	}
	
	public void takeOff(FightCard fightCard, ActionRecorder actionRecorder) {
		if (fightCard.equals(this.weaponCard)){
			actionRecorder.addLocation(this.getWeaponCard(),  CardLocation.DISCARD);
			BuffData bd = mainCard.removeBuff(this.getWeaponCard().getId());
			actionRecorder.addAction(new BuffAction(mainCard, bd, 0));
			this.weaponCard = null;
		}
		if (fightCard.equals(this.defCard)){
			actionRecorder.addLocation(this.getDefCard(),  CardLocation.DISCARD);
			BuffData bd = mainCard.removeBuff(this.getDefCard().getId());
			actionRecorder.addAction(new BuffAction(mainCard, bd, 0));
			this.defCard = null;
		}
		if (fightCard.equals(this.itemCard)){
			actionRecorder.addLocation(this.getItemCard(),  CardLocation.DISCARD);
			this.itemCard = null;
		}
	}
	
	
	
	
}
